package live.ifox.factory;

import android.os.Build;
import android.os.Build.VERSION;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SystemInfo {
    private List<Map<String, Object>> infoModel;

    public SystemInfo() {
        infoModel = new ArrayList<>();
    }

    private void addItem(String label, Object detail) {
        Map<String, Object> map = new HashMap<>();
        map.put("label", label);
        map.put("detail", detail);
        infoModel.add(map);
    }

    public Map<String, Object> getBuildInfo() {
        Map<String, Object> map = new HashMap<>();
        map.put("BOARD", Build.BOARD);
        map.put("BOOTLOADER", Build.BOOTLOADER);
        map.put("BRAND", Build.BRAND);
        map.put("DEVICE", Build.DEVICE);
        map.put("Display", Build.DISPLAY);
        map.put("Fingerprint", Build.FINGERPRINT);
        map.put("Hardware", Build.HARDWARE);
        map.put("Host", Build.HOST);
        map.put("ID", Build.ID);
        map.put("Manufacturer", Build.MANUFACTURER);
        map.put("Model", Build.MODEL);
        map.put("Product", Build.getRadioVersion());
        // map.put("Serial",Build.getSerial());
        map.put("Tags", Build.TAGS);
        map.put("Type", Build.TYPE);
        map.put("User", Build.USER);
        // map.put("BaseOS",VERSION.BASE_OS);
        map.put("CodeName", VERSION.CODENAME);
        map.put("Release", VERSION.RELEASE);
        // map.put("SDK",VERSION.SECURITY_PATCH);
        map.put("SDK_INT", VERSION.SDK_INT);
        return map;

        /*
        Map<String, String> map = new HashMap<>();
        for (Map.Entry<String, String> entry : map.entrySet()) {
        System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); }
        */
    }

    public Map<String, Object> getSystemInfo() {
        Map<String, Object> map = new HashMap<>();
        map.put("os.version", System.getProperty("os.version"));
        map.put("os.name", System.getProperty("os.name"));
        map.put("os.arch", System.getProperty("os.arch"));
        map.put("java.version", System.getProperty("java.version"));
        return map;
    }

    public List<Map<String, Object>> getModel() {
        addItem("BOARD", Build.BOARD);
        addItem("BOOTLOADER", Build.BOOTLOADER);
        addItem("BRAND", Build.BRAND);
        addItem("DEVICE", Build.DEVICE);
        addItem("Display", Build.DISPLAY);
        addItem("Fingerprint", Build.FINGERPRINT);
        addItem("Hardware", Build.HARDWARE);
        addItem("Host", Build.HOST);
        addItem("ID", Build.ID);
        addItem("Manufacturer", Build.MANUFACTURER);
        addItem("Model", Build.MODEL);
        addItem("Product", Build.getRadioVersion());
        // ("Serial",Build.getSerial());
        addItem("Tags", Build.TAGS);
        addItem("Type", Build.TYPE);
        addItem("User", Build.USER);
        // ("BaseOS",VERSION.BASE_OS);
        addItem("CodeName", VERSION.CODENAME);
        addItem("Release", VERSION.RELEASE);
        // ("SDK",VERSION.SECURITY_PATCH);
        addItem("SDK_INT", String.valueOf(VERSION.SDK_INT));
        addItem("os.version", System.getProperty("os.version"));
        addItem("os.name", System.getProperty("os.name"));
        addItem("os.arch", System.getProperty("os.arch"));
        addItem("user.dir", System.getProperty("user.dir"));
        addItem("user.name", System.getProperty("user.name"));
        addItem("user.home", System.getProperty("user.home"));
        addItem("java.version", System.getProperty("java.version"));
        addItem("java.vm.version", System.getProperty("java.vm.version"));
        addItem("java.vm.name", System.getProperty("java.vm.name"));
        return infoModel;
    }
}
